home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM B4 / PD-ROM B4.iso / Entertainment / Strategy / Robots / bot 1.0.1 / Tutorial / BASIC / Seeker < prev    next >
Text File  |  1991-07-19  |  1KB  |  42 lines

  1. !
  2. ! Seeker
  3. !
  4. ! This bot scans around in a circle until it finds another bot.
  5. ! It locks on to the bot, firing until the enemy bot leaves the
  6. ! arc of the scanner.  Then it resumes scanning.
  7. !
  8.  
  9. #DATA
  10.  
  11.  
  12. DEF scanAt              ! Current scan angle
  13.  
  14. EQU INCREMENT 7         ! Amount to add to scan angle each time
  15.  
  16.  
  17. #CODE BASIC
  18.  
  19. :Initialize
  20.     scanAt = Random(360)        ! Start at a random angle
  21.  
  22. :ScanLoop
  23.     scanAt = scanAt + INCREMENT
  24.     Scan Angle scanAt
  25.     If ($FOUND == 0) Then Goto ScanLoop
  26.                         ! $FOUND == 0 means that nothing was
  27.                         ! found.
  28.                         ! ... so continue around in a circle
  29.                         ! ... otherwise, go on to ScanLock
  30. :ScanLock
  31.     Fire Weapon 1,  &   ! Fire the (primary) weapon
  32.          Angle $ANGLE   ! At the angle returned by the scanner.
  33.                         ! The '&' allows you to continue a line
  34.                         ! of code on the next line.
  35.     Scan Angle scanAt   ! Check to see if enemy is still there
  36.     If ($FOUND == 0) Then
  37.         Goto ScanLoop   ! If not, resume scanning
  38.     Goto ScanLock       ! If so, keep firing until he dies or
  39.                         !   moves.
  40.  
  41. #END
  42.